<script setup>
import {onMounted, ref} from 'vue'
import {reqLikeListAPI} from '@/api/user'
import GoodsIndex from '@/components/goods/GoodsIndex.vue'
import {useUserStore} from '@/store/userStore'

const userStore = useUserStore()

// 挂载获取用户喜欢的商品列表
onMounted(() => {
  getLikeList()
})
const likeList = ref([])
const getLikeList = async () => {
  const res = await reqLikeListAPI({limit: 4})
  likeList.value = res.data.result
}


</script>

<template>
  <div class="userinfo-index">
    <div class="userinfo-header">
      <div class="avatar">
        <img :src="userStore.userInfo?.avatar" alt=""/>
        <h2>{{ userStore.userInfo?.account || '未登录' }}</h2>
      </div>
      <div class="actions">
        <RouterLink to="/my/account">
          <el-icon>
            <GoldMedal/>
          </el-icon>
          <p>会员中心</p>
        </RouterLink>
        <RouterLink to="/home">
          <el-icon>
            <Setting/>
          </el-icon>
          <p>安全设置</p>
        </RouterLink>
        <RouterLink to="/home">
          <el-icon>
            <MapLocation/>
          </el-icon>
          <p>地址管理</p>
        </RouterLink>
      </div>

    </div>
    <div class="userinfo-body">
      <div class="header">
        <h4 data-v-bcb266e0="">猜你喜欢</h4>
      </div>
      <div class="goods-list">
        <GoodsIndex v-for="goods in likeList" :key="goods.id" :goods="goods"/>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.userinfo-index {
  width: 100%;
  height: 550px;
  display: flex;
  flex-direction: column;

  .userinfo-header {
    height: 132px;
    display: flex;
    padding: 20px;
    background: url(@/assets/images/center-bg.png) no-repeat center / cover;

    .avatar {
      flex: 1;
      display: flex;
      align-items: center;

      img {
        width: 80px;
        height: 80px;
        border-radius: 50%;
        margin: 0 30px;
      }

      h2 {
        font-size: 24px;
        color: #fff;
      }
    }

    .actions {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: space-around;

      a {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 10px;
        color: #fff;

        .el-icon {
          font-size: 26px;
        }

        p {
          font-size: 18px;
          margin-top: 5px;
        }
      }

    }
  }

  .userinfo-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;

    .header {
      width: 100%;
      height: 60px;
      border-bottom: 1px solid #eaeaea;
      padding: 20px;
      display: flex;
      align-items: center;

      h4 {
        font-size: 24px;
      }

    }

    .goods-list {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      align-items: center;
      width: 100%;
      height: 350px;
    }


  }

}


</style>